
Imports System
Imports System.Data.SqlClient


Namespace _2bMatesSite.BO
	''' <summary>
	''' A single comment about a picture.
	''' </summary>
	Public Class PictureComment
		Protected commentID As Integer
		Protected pictureID As Integer
		Protected fromUserID As Integer
		Protected comment As String
		Protected status As Status
		Protected [date] As DateTime

		Public Enum Status
			pcsNew = 0
			pcsAccepted = 1
			pcsNewAccepted = 2
			' new accepted comment - used when the user has switched off approval of comments
		End Enum

		Public Sub New(ByVal pictureID As Integer, ByVal fromUserID As Integer, ByVal comment As String)
			commentID = -1
			Me.pictureID = pictureID
			Me.fromUserID = fromUserID
			Me.comment = comment

			status = Status.pcsNew
			[date] = DateTime.Now
		End Sub

		Public Sub New(ByVal dr As SqlDataReader)
			commentID = dr.GetInt32(dr.GetOrdinal("ID"))
			comment = dr.GetString(dr.GetOrdinal("Comment"))
			pictureID = dr.GetInt32(dr.GetOrdinal("PictureID"))
			fromUserID = dr.GetInt32(dr.GetOrdinal("UID"))
			status = DirectCast(dr.GetInt32(dr.GetOrdinal("Status")), Status)
			[date] = dr.GetDateTime(dr.GetOrdinal("Date"))
		End Sub

		Public ReadOnly Property ID() As Integer
			Get
				Return commentID
			End Get
		End Property

		Public ReadOnly Property PictureID() As Integer
			Get
				Return pictureID
			End Get
		End Property

		Public ReadOnly Property PostedByUserID() As Integer
			Get
				Return fromUserID
			End Get
		End Property

		Public ReadOnly Property Comment() As String
			Get
				Return comment
			End Get
		End Property

		Public Property CommentStatus() As Status
			Get
				Return status
			End Get
			Set
				status = value
			End Set
		End Property

		Public ReadOnly Property [Date]() As DateTime
			Get
				Return [date]
			End Get
		End Property
	End Class
End Namespace






